﻿/*
* Author:  YPN
* Created: 2022/07/02 15:41:57
* Contact: yangpiena@163.com
* Description: 
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ypn.common.csharp
{
    public class DateTimeHelper
    {
        /// <summary>
        /// 格式化日期时间
        /// </summary>
        /// <param name="i_dateTime">要格式化的日期时间</param>
        /// <param name="i_mode">模式</param>
        /// <returns></returns>
        public static string FormatDateTime(DateTime i_dateTime, string i_mode)
        {
            switch (i_mode)
            {
                case "0":
                    return i_dateTime.ToString("yyyy-MM-dd");
                case "1":
                    return i_dateTime.ToString("yyyy-MM-dd HH:mm:ss");
                case "2":
                    return i_dateTime.ToString("yyyy/MM/dd");
                case "3":
                    return i_dateTime.ToString("yyyy年MM月dd日");
                case "4":
                    return i_dateTime.ToString("MM-dd");
                case "5":
                    return i_dateTime.ToString("MM/dd");
                case "6":
                    return i_dateTime.ToString("MM月dd日");
                case "7":
                    return i_dateTime.ToString("yyyy-MM");
                case "8":
                    return i_dateTime.ToString("yyyy/MM");
                case "9":
                    return i_dateTime.ToString("yyyy年MM月");
                case "10":
                    return i_dateTime.ToString("yyyyMMddHHmmss");
                default:
                    return i_dateTime.ToString();
            }
        }
    }
}
